/**
 * Created with JetBrains PhpStorm.
 * User: shaoshuai
 * Date: 12-7-13
 */
/**
 * @class FlyFight.view.airplane.F15
 */
FlyFight.view.airplane.F15 = Zen.extend(Zen.View, {
    initView: function () {
        /**
         * @type {String}
         * @private
         */
        this._id = 'f15';
        this.model = new FlyFight.model.airplane.F15();
        this.el = FlyFight.view.airplane.Renderer.createEl(this.model);
        this.el.draggable({
            revert: 'invalid'
        });
    },
    /**
     * @param {Object} position
     * @return {FlyFight.view.airplane.F15}
     */
    render: function (position) {
        jQuery('body').append(this.el);
        this.el.offset(position);
        return this;
    },
    getOffset: function () {
        return this.el.offset();
    },
    getId: function () {
        return this._id;
    },
    getCoordinate: function (chessboard) {
        var chessboardOffset = chessboard.getOffset();
        var myOffset = this.el.offset();

        chessboardOffset.top++;
        chessboardOffset.left++;

        var coordinate = {
            x: 0,
            y: 0
        };

        coordinate.x = (myOffset.left - chessboardOffset.left) / (FlyFight.view.CELL_WIDTH_HEIGHT + 1);
        coordinate.y = (myOffset.top - chessboardOffset.top) / (FlyFight.view.CELL_WIDTH_HEIGHT + 1);

        return coordinate;
    }
});
